package com.bnz.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@WebListener
public class MySessionListener implements HttpSessionListener, HttpSessionAttributeListener {

	//1. 对session组件的监听
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		System.out.println("session被创建。。。");
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		System.out.println("session被销毁...");
	}

	//2. 对session中属性值变化的监听
	@Override
	public void attributeAdded(HttpSessionBindingEvent event) {
		System.out.println("为session添加一个属性值。。。");
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent event) {
		System.out.println("从session中移除一个属性值。。。");
	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent event) {

	}

}
